package com.woniu.controller;

import com.woniu.pojo.Userrole;
import com.woniu.service.UserroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("userrole")
public class UserroleController {
    @Autowired
    private UserroleService userroleService;
    @RequestMapping("assignRoleDo")
    @ResponseBody
    public Map<String,Object> assignRoleDo(Userrole userrole){
        Map<String,Object> resutlMap = new HashMap<>();
        try{
            userroleService.assignRole(userrole);
            resutlMap.put("result",true);
        }catch (Exception e){
            resutlMap.put("result",false);
        }
        return resutlMap;
    }
    @RequestMapping("unAssignRoleDo")
    @ResponseBody
    public Map<String,Object> unAssignRoleDo(Userrole userrole){
        Map<String,Object> resutlMap = new HashMap<>();
        try{
            userroleService.unAssignRole(userrole);
            resutlMap.put("result",true);
        }catch (Exception e){
            resutlMap.put("result",false);
        }
        return resutlMap;
    }
}
